<script type="text/javascript">
function delEntry(entry, url)
{
	var valid = confirm('<?=$this->translate->_('messages_delete_confirm')?>');
	
	if(valid)
	{
		$.post(url, { uid: entry }, function(data) {
			$("#"+ entry).fadeOut("slow");
		});
	}
}
</script>

<h1><?=$this->translate->_('messages_header')?></h1>
<p><?=$this->translate->_('messages_text')?></p>

<p><img style="position:relative; top:4px;" src="<?=$this->baseUrl()?>/static/gfx/icons/email.png" /> <?=$this->translate->_('messages_inbox')?> - <img style="position:relative; top:4px;" src="<?=$this->baseUrl()?>/static/gfx/icons/email_go.png" /> <a href="<?=$this->url(array('controller' => 'messages', 'action' => 'outbox'), 'messages_outbox', true)?>"><?=$this->translate->_('messages_outbox')?></a></p>

<? if($this->count > 0):?>
	
	<?=$this->paginationControl($this->results, 'Sliding', 'pagination_control.phtml', array('route' => 'messages_p'))?>

	<table class="table_messages" summary="personal messages" cellpadding="5px" cellspacing="0">
	<thead>
		<tr>
			<th width="16px"></th>
			<th><?=$this->translate->_('messages_title')?></th>
			<th><?=$this->translate->_('messages_from')?></th>
			<th><?=$this->translate->_('messages_received')?></th>
			<th width="16px"></th>
		</tr>
	</thead>
	<? foreach($this->results AS $row): ?>
		<tr id="<?=$row['uid']?>">
			<td>
				<? if($row['is_read'] == 0):?>
					<img alt="<?=$this->translate->_('messages_unread')?>" src="<?=$this->baseUrl()?>/static/gfx/email.png" />
				<? else: ?>
					<img alt="<?=$this->translate->_('messages_read')?>" src="<?=$this->baseUrl()?>/static/gfx/email_open.png" />
				<? endif; ?>
			</td>
			<td class="middle"><a class="<? if($row['is_read'] == 0): echo 'message1'; else: echo 'message2'; endif; ?>" href="<?=$this->url(array('controller' => 'messages', 'action' => 'show', 'uid' => $row['uid']), 'messages_s', true)?>"><?=$this->escape($row['title'])?></a></td>
			<td class="middle"><?if($row['is_notice'] == 1): echo $this->translate->_('system_author'); else: echo $this->GetAuthor($row['user_uid']); endif;?></td>
			<td class="middle"><?=$this->datetime($row['create_date'])?></td>
			<td class="middle">
				<a href="javascript:delEntry(<?=$row['uid']?>,'<?=$this->url(array('controller' => 'messages', 'action' => 'delete'), 'default', true)?>');">
					<img alt="<?=$this->translate->_('messages_delete')?>" src="<?=$this->baseUrl()?>/static/gfx/icons/bin.png" />
				</a>
			</td>
		</tr>
		
		<tr id="row<?=$row['uid']?>" style="display:none;">
			<td colspan="5" class="item_desc"><?=$this->replyForm?></td>
		</tr>
	<? endforeach; ?>
	</table>
	<br />
	<?=$this->paginationControl($this->results, 'Sliding', 'pagination_control.phtml', array('route' => 'messages_p'))?>
	
<? else: ?>
	<p class="notice"><?=$this->translate->_('messages_empty')?></p>
<? endif; ?>